package com.flymobi.admin;

import java.util.Calendar;
import java.util.List;

import com.flymobi.fw.modules.SM;
import com.flymobi.fw.util.DateUtil;
import com.flymobi.fw.util.StringUtil;
import com.flymobi.po.Manager;
import com.flymobi.po.SpChongzhiLog;
import com.flymobi.util.Pagination;
import com.flymobi.util.WebContext;
import com.flymobi.vo.SpChongzhiLogSearchVo;

/**
 * 
 * 
 * Title:
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2008
 * 
 * @author haoxz11
 * @created Oct 21, 2008 11:16:42 AM
 * @version $Id: ManagerAction.java,v 1.1 2010/04/09 03:27:08 airsou Exp $
 */
public class SpChongzhiLogAction extends WebAction {
	private String s;
	private String e;

	/**
	 * @return the s
	 */
	public String getS() {
		return s;
	}

	/**
	 * @param s
	 *            the s to set
	 */
	public void setS(String s) {
		this.s = s;
	}

	/**
	 * @return the e
	 */
	public String getE() {
		return e;
	}

	/**
	 * @param e
	 *            the e to set
	 */
	public void setE(String e) {
		this.e = e;
	}

	private SpChongzhiLogSearchVo searchparam;

	/**
	 * @return the searchparam
	 */
	public SpChongzhiLogSearchVo getSearchparam() {
		return searchparam;
	}

	/**
	 * @param searchparam
	 *            the searchparam to set
	 */
	public void setSearchparam(SpChongzhiLogSearchVo searchparam) {
		this.searchparam = searchparam;
	}

	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String webProcess(WebContext context, Manager manager) {
		if (searchparam == null) {
			searchparam = new SpChongzhiLogSearchVo();
		}
		if ("list".equals(method)) {
			if (!StringUtil.isEmpty(s)) {
				searchparam.setStart(DateUtil.parseStrDate(s, "yyyy-MM-dd"));
			}
			if (!StringUtil.isEmpty(e)) {
				searchparam.setEnd(DateUtil.parseStrDate(e, "yyyy-MM-dd"));
			}
			if (searchparam == null) {
				searchparam = new SpChongzhiLogSearchVo();
			}
			if (searchparam.getStart() == null) {
				Calendar calendar = Calendar.getInstance();
				calendar.set(Calendar.DAY_OF_MONTH, 1);
				calendar.set(Calendar.HOUR_OF_DAY, 0);
				calendar.set(Calendar.MINUTE, 0);
				calendar.set(Calendar.SECOND, 0);
				calendar.set(Calendar.MILLISECOND, 0);
				searchparam.setStart(calendar.getTime());
			}
			if (searchparam.getEnd() == null) {
				Calendar calendar = Calendar.getInstance();
				calendar.add(Calendar.DAY_OF_MONTH, 1);
				calendar.set(Calendar.HOUR_OF_DAY, 0);
				calendar.set(Calendar.MINUTE, 0);
				calendar.set(Calendar.SECOND, 0);
				calendar.set(Calendar.MILLISECOND, 0);
				searchparam.setEnd(calendar.getTime());
			}
			List<SpChongzhiLog> spLogList = SM.SpChongzhiLogService.list(
					searchparam, startRow, pagePerSize);
			context.put("spLogList", spLogList);
			Pagination pagination = new Pagination(SM.SpChongzhiLogService
					.getCount(searchparam).intValue(), startRow, pagePerSize);
			context.put("pagination", pagination);
			return "list";
		} else {
			method = "list";
			return this.webProcess(context, manager);
		}
	}
}
